import Vue from 'vue'
import App from './App.vue'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import router from './router'
import './assets/css/global.css'
import store from './store/index';
import axios from 'axios'
import md5 from 'js-md5';
Vue.prototype.$md5 = md5;

axios.defaults.baseURL="http://120.46.132.13:8081/"

axios.interceptors.request.use(function (config) {
  // 在发送请求之前做些什么
  // 判断是否存在token,如果存在将每个页面header添加token
  if(sessionStorage.getItem("token")!=null){
    config.headers.common['token'] = sessionStorage.getItem("token");
  }
  return config
}, function (error) {
  router.push('/')
  return Promise.reject(error)
})

Vue.config.productionTip = false
Vue.use(ElementUI)
Vue.prototype.$http=axios

new Vue({
  router,
  store,
  render: h => h(App),
}).$mount('#app')

document.title="图书电商平台"


